home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
FishMarket 1.0
/
FishMarket v1.0.iso
/
fishies
/
376-400
/
disk_398
/
dclock
/
dclockmenu.rexx
< prev
next >
Wrap
OS/2 REXX Batch file
|
1992-05-06
|
13KB
|
450 lines
/* DClockMenu.rexx by Stefan Sticht PUBLIC DOMAIN
DClockMenu is a short ARexx program which allows you to change
the options of DClock v1.20+ easily via requesters.
*/
VERSION = "v1.24"
SIGNAL ON HALT /* tell arexx to signal us that the HI */
SIGNAL ON BREAK_C /* command has been used and trap also */
SIGNAL ON BREAK_D /* break signals */
SIGNAL ON BREAK_E
SIGNAL ON BREAK_F
OPTIONS FAILAT 20
OPTIONS RESULTS /* Allow DClock to send results */
ADDRESS "DCLOCK" /* DClock shall be our host */
PARSE ARG argument /* get command line arguments */
IF argument = "?" THEN EXIT(info())
/* we require the rexxsupport.library; is it available ? */
IF ~SHOW(LIBRARIES,"rexxsupport.library") THEN DO
IF EXISTS("libs:rexxsupport.library") THEN DO
CALL ADDLIB("rexxsupport.library",0,-30)
END
ELSE DO
SAY "DClockMenu requires the rexxsupport.library!"
SAY "It can be found on your ARexx Disk. Please copy the"
SAY "library to your 'libs:' directory!"
EXIT
END
END
/* we require the rexxarplib.library; is it available ? */
IF ~SHOW(LIBRARIES,"rexxarplib.library") THEN DO
IF EXISTS("libs:rexxarplib.library") THEN DO
CALL ADDLIB("rexxarplib.library",0,-30)
END
ELSE DO
SAY "DClockMenu requires the rexxarplib.library v2.3 or later!"
SAY "It can be found on your ARexx Disk. Please copy the"
SAY "library to your 'libs:' directory!"
EXIT
END
END
dclock.on = SHOW("PORTS","DCLOCK") /* is DClock already running ? */
IF ~dclock.on THEN DO
CALL req("DClock has to be started first!")
EXIT
END
/*
* Get all current settings from DClock
*/
STATUS
/* remove comment for debugging */
SAY RESULT
PARSE VAR RESULT . dclock.beep . dclock.click . dclock.clickvolume,
. dclock.priority . dclock.textcolor . dclock.backcolor,
. dclock.alarm . dclock.alarmtime . dclock.setenv,
. dclock.version . dclock.countdown . dclock.hour,
. dclock.seconds . dclock.sound . dclock.page . dclock.speech,
. dclock.line
IF dclock.beep ~= "ON" & dclock.beep ~= "OFF" THEN DO
CALL req("Sorry, error in DClock's STATUS!")
EXIT
END
ADDRESS AREXX "'CALL CreateHost(DCHOST,DCPORT,)'" /* create */
DO FOR 50 WHILE ~SHOW("PORTS","DCHOST") /* a new host */
CALL DELAY(10) /* for us */
END
IF ~SHOW("PORTS","DCHOST") THEN DO /* did the host really open ? */
CALL req("Can't create a new host!") /* no, so quit */
EXIT
END
CALL SETREQCOLOR(DCHOST, BLOCKPEN, 1) /* change color of window */
CALL SETREQCOLOR(DCHOST, DETAILPEN, 0)
idcmp = "CLOSEWINDOW GADGETUP MENUPICK"
flags = "ACTIVATE WINDOWDRAG WINDOWDEPTH WINDOWCLOSE"
width = 415
height = 150
leftedge = (SCREENCOLS() - width) % 2
topedge = 20
ok = OPENWINDOW(DCHOST,leftedge,topedge,width,height,idcmp,flags,,
"DClock Menu")
IF ~ok THEN DO
CALL req("Can't open window!")
CALL QUIT(DCHOST)
EXIT
END
ok = OPENPORT(DCPORT) /* open the message port */
IF ~ok THEN DO
CALL req("Can't open new message port!")
CALL QUIT(DCHOST)
EXIT
END
/*
* Menus
*/
CALL SETAPEN(DCHOST,2) /* change detail pen */
CALL ADDMENU(DCHOST,"DClock Menu") /* add a menu */
CALL ADDITEM(DCHOST,"Version","VERSION","V",,) /* and two items */
CALL ADDITEM(DCHOST,"Quit","CLOSEWINDOW","Q",,)
/*
* Gadgets:
*/
ontext = " ON "
offtext = " OFF "
fontB = 7 /* Baseline offset */
x = 20 /* LeftEdge of first gadget */
y = 20 /* TopEdge of first gadget */
dx = 100 /* horizontal offset of second gadget row */
dy = 18 /* vertical offset of next gadget */
gadhsize = 45 /* horizontal size of simple string gadget */
/*
* Switches:
*/
gid.beep = 1
CALL ADDGADGET(DCHOST, x, y, gid.beep, " BEEP ", "BEEP")
CALL SETGADGET(DCHOST, gid.beep, dclock.beep)
gid.click = gid.beep + 1
CALL ADDGADGET(DCHOST, x + dx, y, gid.click, " CLICK ", "CLICK")
CALL SETGADGET(DCHOST, gid.click, dclock.click)
gid.alarm = gid.click + 1
CALL ADDGADGET(DCHOST, x + dx + dx, y, gid.alarm, " ALARM ", "ALARM")
CALL SETGADGET(DCHOST, gid.alarm, dclock.alarm)
gid.setenv = gid.alarm + 1
CALL ADDGADGET(DCHOST, x + dx + dx + dx, y, gid.setenv, " SETENV ", "SETENV")
CALL SETGADGET(DCHOST, gid.setenv, dclock.setenv)
y = y + dy
gid.hour = gid.setenv + 1
CALL ADDGADGET(DCHOST, x, y, gid.hour, " HOUR ", "HOUR")
CALL SETGADGET(DCHOST, gid.hour, dclock.hour)
gid.seconds = gid.hour + 1
CALL ADDGADGET(DCHOST, x + dx, y, gid.seconds, " SECONDS ", "SECONDS")
CALL SETGADGET(DCHOST, gid.seconds, dclock.seconds)
/*
* Stringgadgets: these definitions are repeated below!
*/
y1 = y + dy
CALL MOVE(DCHOST, x, y1 + fontB)
CALL TEXT(DCHOST,"ALARMTIME:")
gid.alarmtime = gid.seconds + 1
CALL ADDGADGET(DCHOST, x + dx, y1, gid.alarmtime, " " ||,
dclock.alarmtime, "ALARMTIME %g", 80)
/* this isn't a string gadget! */
CALL MOVE(DCHOST, x + dx + dx, y1 + fontB)
CALL TEXT(DCHOST,"SOUNDFILE:")
gid.sound = gid.alarmtime + 1
CALL ADDGADGET(DCHOST, x + 3 * dx, y1, gid.sound, CENTER(dclock.sound, 5),,
"SOUND")
y2 = y1 + dy;
CALL MOVE(DCHOST, x, y2 + fontB)
CALL TEXT(DCHOST,"COUNTDOWN:")
gid.countdown = gid.sound + 1
CALL ADDGADGET(DCHOST, x + dx, y2, gid.countdown, CENTER(dclock.countdown, 7),,
"COUNTDOWN %g", gadhsize)
CALL MOVE(DCHOST, x + dx + dx, y2 + fontB)
CALL TEXT(DCHOST,"PRIORITY:")
gid.priority = gid.countdown + 1
CALL ADDGADGET(DCHOST, x + 3 * dx, y2, gid.priority, CENTER(dclock.priority, 7),,
"PRIORITY %g", gadhsize)
y3 = y2 + dy;
CALL MOVE(DCHOST, x, y3 + fontB)
CALL TEXT(DCHOST,"TEXTCOLOUR:")
gid.textcolour = gid.priority + 1
CALL ADDGADGET(DCHOST, x + dx, y3, gid.textcolor, CENTER(dclock.textcolor, 7),,
"TEXTCOLOR %g", gadhsize)
CALL MOVE(DCHOST, x + dx + dx, y3 + fontB)
CALL TEXT(DCHOST,"BACKCOLOUR:")
gid.backcolour = gid.textcolour + 1
CALL ADDGADGET(DCHOST, x + 3 * dx, y3, gid.backcolor,,
CENTER(dclock.backcolor, 7), "BACKCOLOR %g", gadhsize)
y4 = y3 + dy;
CALL MOVE(DCHOST, x, y4 + fontB)
CALL TEXT(DCHOST,"CLICKVOLUME:")
gid.clickvol = gid.backcolour + 1
CALL ADDGADGET(DCHOST, x + dx, y4, gid.clickvol, CENTER(dclock.clickvolume, 7),,
"CLICKVOLUME %g", gadhsize)
/*
* Call the main-routine:
*/
CALL lookport()
EXIT
/*
* lookport: watch our message port for incoming messages
*/
lookport:
quitflag = 0
DO FOREVER UNTIL quitflag
CALL WAITPKT(DCPORT)
pkt = GETPKT(DCPORT)
IF pkt ~= NULL() THEN DO
arg = GETARG(pkt)
CALL REPLY(pkt, 0)
SELECT
WHEN arg = "CLOSEWINDOW" THEN quitflag = 1
WHEN arg = "VERSION" THEN CALL version()
WHEN LEFT(arg,9) = "CLICKVOLU" THEN CALL clickvol(arg)
WHEN LEFT(arg,9) = "ALARMTIME" THEN CALL alarmtime(arg)
WHEN LEFT(arg,9) = "COUNTDOWN" THEN CALL countdown(arg)
WHEN LEFT(arg,8) = "PRIORITY" THEN CALL priority(arg)
WHEN LEFT(arg,9) = "TEXTCOLOR" THEN CALL textcolor(arg)
WHEN LEFT(arg,9) = "BACKCOLOR" THEN CALL backcolor(arg)
WHEN arg = "SOUND" THEN CALL soundfile
WHEN arg = "REMOVE" THEN NOP
WHEN arg = "REFRESH" THEN NOP
OTHERWISE CALL switch(arg)
END
END
END
CALL quitcleanup("ok")
RETURN(0)
/*
* quitcleanup: close all opened resources and exit
*/
quitcleanup:
PARSE ARG msg
CALL CLOSEPORT(DCPORT)
CALL QUIT(DCHOST)
IF msg ~= "ok" THEN SAY msg
EXIT
/*
* switch: change the status of a option
*/
switch: PROCEDURE EXPOSE dclock. gid.
ARG option
IF dclock.option = "ON" THEN dclock.option = "OFF"
ELSE dclock.option = "ON"
INTERPRET option dclock.option
CALL SETGADGET(DCHOST, gid.option, dclock.option)
RETURN(0)
/*
* version: display current DClock Version number
*/
version: PROCEDURE
STATUS VERSION
text = "DClock V1." || RESULT "is installed."
CALL req(text)
RETURN(0)
/*
* alarmtime: a new time has been entered, check it
*/
alarmtime: PROCEDURE
PARSE ARG time
time = SUBWORD(time,2,1)
IF LENGTH(time) = 8 THEN DO
ALARMTIME time
IF RC > 0 THEN DO
CALL req("Can't change alarmtime!\Perhaps invalid format?")
END
END
ELSE CALL req("Alarm time format has to be in the format HH:MM:SS!")
RETURN(0)
/*
* countdown: a new time has been entered, check it
*/
countdown: PROCEDURE EXPOSE dclock.
PARSE ARG count
count = SUBWORD(count, 2, 1)
IF DATATYPE(count, "NUMERIC") THEN DO
COUNTDOWN count
dclock.countdown = count
END
ELSE CALL req("Countdown has to be a numeric value!")
RETURN(0)
/*
* priority: a new priority has been entered
*/
priority: PROCEDURE EXPOSE dclock.
PARSE ARG pri
pri = SUBWORD(pri, 2, 1)
IF DATATYPE(pri, "NUMERIC") THEN DO
IF (pri >= -127 & pri <= 127) THEN DO
PRIORITY pri
dclock.priority = pri
END
ELSE DO
CALL req("Illegal value for handler task priority\" ||,
"(must be between -127 and 127)!")
END
END
ELSE CALL req("Priority must be numeric!")
RETURN(0)
/*
* textcolor: textcolour has been changed
*/
textcolor: PROCEDURE EXPOSE dclock.
PARSE ARG col
col = SUBWORD(col, 2, 1)
IF DATATYPE(col, "NUMERIC") THEN DO
TEXTCOLOUR col
dclock.textcolor = col
END
ELSE CALL req("TEXTCOLOR must be numeric!")
RETURN(0)
/*
* backcolor: backcolour has been changed
*/
backcolor: PROCEDURE EXPOSE x dx y3 gadhsize
PARSE ARG col
col = SUBWORD(col, 2, 1)
IF DATATYPE(col, "NUMERIC") THEN DO
BACKCOLOUR col
IF RC > 0 THEN req("Can't change background colour!")
END
ELSE CALL req("BACKCOLOR must be numeric!")
RETURN(0)
/*
* clickvol: the clickvolume has been changed
*/
clickvol: PROCEDURE EXPOSE x dx y4 gadhsize gid.
PARSE ARG vol
error = 0
vol = SUBWORD(vol, 2, 1)
IF DATATYPE(vol, "NUMERIC") THEN DO
IF vol <0 | vol > 64 THEN DO
CALL req("Illegal value for click volume\" ||,
"(must be between 0 and 64)!")
error = 1
END
ELSE DO
CLICKVOLUME vol
IF RC > 0 THEN DO
req("Can't change clickvolume")
error = 1
END
END
END
ELSE DO
CALL req("CLICKVOLUME must be numeric!")
error = 1
END
IF error THEN DO
CALL REMOVEGADGET(DCHOST, gid.clickvol)
STATUS CLICKVOLUME
CALL ADDGADGET(DCHOST, x + dx, y4, gid.clickvol, " " RESULT,,
"CLICKVOLUME %g", gadhsize)
END
RETURN(0)
/*
* soundfile:
*/
soundfile: PROCEDURE EXPOSE dclock.sound x dx y1 gid.
STATUS SOUND
dclock.sound = RESULT
IF dclock.sound ~= "OFF" THEN SOUND OFF
ELSE DO
file = GETFILE(0, 12, , , "Select sound file:")
IF file ~= "" THEN DO
IF ~EXISTS(file) THEN req("Can't find that file!")
ELSE DO
SOUND file
IF RC > 0 THEN req("Can't load that file!")
END
END
END
STATUS SOUND
dclock.sound = RESULT
CALL REMOVEGADGET(DCHOST, gid.sound)
CALL ADDGADGET(DCHOST, x + 3 * dx, y1, gid.sound,,
CENTER(dclock.sound, 5), "SOUND")
RETURN(0)
/*
* info: display some information about DClockMenu
*/
info: PROCEDURE EXPOSE version
SAY "
DClockMenu
" version "by Stefan Sticht"
SAY "Usage: DClockMenu"
SAY
SAY SOURCELINE(3)
SAY SOURCELINE(4)
SAY
RETURN(0)
/*
* req: call the requester of the rexxarplib.library with msg
*/
req: PROCEDURE
PARSE ARG msg
CALL REQUEST(0,12,msg,,," OK ",)
RETURN(0)
BREAK_C: /* somebody wants to kill us, but before we leave */
BREAK_D: /* we have to clean up */
BREAK_E:
BREAK_F:
HALT:
CALL quitcleanup("***user break")
EXIT